﻿using Refugees.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Refugees.Views.Windows
{
    public partial class ContactNumbers : Window
    {
        Repositories.OrganizationRepository organizationRepository = new Repositories.OrganizationRepository();
        public ContactNumbers()
        {
            InitializeComponent();
            Organiztion.ItemsSource = organizationRepository.GetOrganizations();
            Organiztion.SelectedIndex = 0;
            if (Repositories.UserRepository.User.role_id != 3)
            {
                NewOrganization.Visibility = Visibility.Collapsed;
            }
            if (Repositories.UserRepository.User.role_id != 2)
            {
                EditOrganization.Visibility = Visibility.Collapsed;
            }
        }

        private void UserClick(object sender, RoutedEventArgs e)
        {
            new Personals().Show();
            Close();
        }

        private void UsliguClick(object sender, RoutedEventArgs e)
        {
            new Uslugies().Show();
            Close();
        }

        private void ContactsClick(object sender, RoutedEventArgs e)
        {
            new ContactNumbers().Show();
            Close();
        }

        private void NewsClick(object sender, RoutedEventArgs e)
        {
            new News().Show();
            Close();
        }
        private void OrganizationSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var organization = Organiztion.SelectedItem as Models.Organization;
           OrganizationName.Text = organization.Name;
            Address.Text = organization.Adress;
            Phone.Text = organization.ContactNummber.ToString();
        }

        private void NewOrganizationClick(object sender, RoutedEventArgs e)
        {
            new OrganizationEdit().Show();
            Close();
        }

        private void EditOrganizationClick(object sender, RoutedEventArgs e)
        {
            new OrganizationEdit(Repositories.UserRepository.User.Organization).Show();
            Close();
        }
    }
}
